package com.zimmur.activemq;

import java.io.UnsupportedEncodingException;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import org.springframework.stereotype.Component;


/**
 * 
 * @author liang
 * @description  Topic消息监听器
 * 
 */
@Component
public class TopicReceiver1 implements MessageListener{


	@Override
	public void onMessage(Message message) {
		try {
			String strMessage;
			
			try {
				strMessage = new String(((TextMessage)message).getText().getBytes(), "utf-8");
				
				System.out.println("TopicReceiver1接收到消息:"+strMessage);
			} catch (UnsupportedEncodingException e2) {
				e2.printStackTrace();
			}
			
			try {
				Thread.sleep(6000);
			}catch (InterruptedException e) {
				e.printStackTrace();
			}
		} catch (JMSException e) {
			e.printStackTrace();
		}
	}
	
}
